package demo;

import java.io.*;
import java.net.*;

public class MyClient {
    public static void main(String[] args) {
        Socket socket = null;
        try {
            socket = new Socket("127.0.0.1",1680);
            PrintWriter out = new PrintWriter(socket.getOutputStream(),true);
            BufferedReader in = new BufferedReader(new InputStreamReader(socket.getInputStream()));
            BufferedReader sin = new BufferedReader(new InputStreamReader(System.in));

            String s;
            do{
                s = sin.readLine();
                out.println(s);
                if(!s.equals("bye")){
                    System.out.println("@服务器回复: " + in.readLine());
                }else{
                    System.out.println("链接关闭");
                }
            }while(!s.equals("bye"));
            out.close();
            in.close();
            socket.close();

        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}
